#coding=utf-8

import subprocess

#child1 = subprocess.Popen(["ls","-l"], stdout=subprocess.PIPE)
#print child1.stdout.read(),
#或者child1.communicate()

import subprocess
child1 = subprocess.Popen(["cat","/etc/passwd"], stdout=subprocess.PIPE)
child2 = subprocess.Popen(["grep","0:0"],stdin=child1.stdout, stdout=subprocess.PIPE)
out = child2.communicate()
print out
